In [1]:
import numpy as np
import igraph as ig
import graph_qa as qa
import cPickle as pickle


/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/SPARQLWrapper/Wrapper.py:88: RuntimeWarning: JSON-LD disabled because no suitable support has been found
  warnings.warn("JSON-LD disabled because no suitable support has been found", RuntimeWarning)

In [2]:
graph = ig.Graph.Read_GraphML('drugbank-ext-v2.grahpml')

Experiment 3

The 'settings' used throughout this experiment

  • Degree-weighted edges. Shortest-paths etc. calculated w.r.t. the degree-corrected distance measure. That is, the edge $(u,v)$ has weight $w(u,v) = \log(\deg(u)) + \log(\deg(v))$.
  • Average-median QA distance. If $A=\{a_1, a_2, a_3\}$ is one multiple choice answer and $Q = \{q_1, \dots, q_n\}$ the question, then the distance $d(A,Q)$ is calculated as \begin{align} d(A,Q) = \text{average}\bigl\{ \; \text{median}\{d(a,q): a \in A \}: \quad q\in Q\;\bigr\} \end{align}

Research question

The four multiple choice answers are all medicines that are all present in Drugbank. They can be found using qa.find_drugbank_entity. The question text, on the other hand, does not contain entities in Drugbank. However, some entities might have entities from the question text in their description. So we try to identify relevant drugbank entities by doing a full-text search over drugbank (using Virtuoso's built-in Precision Search). Clearly, this representation is not perfect: if we select only a few entities, which are actually unrelated, a good result seems implausible. So we examine this: what is the (very rough) effect of the number of entities we pick from the ranked full-text search results?


In [3]:
def perform_experiment_3(setup,
        trials=[2,5,10,15,20,25,50,75,100,200,400,700,1000,1500]):
    """Performs experiment 3
    """
    setup['description'] = """
        The four multiple choice answers are all medicines that are all present in Drugbank. 
        They can be found using `qa.find_drugbank_entity`. 
        The question text, on the other hand, does not contain entities in Drugbank. 
        However, some entities might have entities from the question text in their description. 
        So we try to identify relevant drugbank entities by doing a full-text search over drugbank 
        (using Virtuoso's built-in Precision Search). 
        Clearly, this representation is not perfect: if we select only a few entities, 
        which are actually unrelated, a good result seems implausible. 
        So we examine this: **what is the (very rough) effect of the number of 
        entities we pick from the ranked full-text search results?**
        """
    setup['settings'] = 'Degree-based weights and average-median qa weights'
    setup['graph'] = 'drugbank-ext-v2.graphml'
    
    q_entities_list = []
    for search_query in setup['q_text_entities']:
        res = qa.search_entities(search_query, None)
        q_entities_list.append(res)

    ans_entities=[]
    for ans in setup['ans_text_entities']:
        if ans[0][0] != '<':
            ans_entities.append(map(qa.find_drugbank_entity, ans))
        else:
            ans_entities.append(ans)

    experiment = []
    for n in trials:

        result = {'n': n}
        q_entities = []
        for qlist in q_entities_list:
            q_entities += qlist[0:n]

        output = qa.rank_qa(graph, q_entities, ans_entities)
        print 'n: '+ str(n) +'    '+str(output)

        result['output'] = output
        result['q_len'] = len(q_entities)
        result['q_entities'] = q_entities
        experiment.append(result)
    
    setup['results'] = experiment
    return setup

Question 2 (Q119#2)

Synthetic analog of deoxyadenosine; active triphosphate form inhibits viral replication by competitively inhibiting HIV reverse transcriptase and by chain termination ;may be prescribed concurrently with zidovudine or given as monotherapy; major clinical toxicity is a dose-dependent pancreatitis.

  1. zalcitabine (Hivid, ddc)
  2. trifluridine (Viroptic)
  3. didanosine (Videx, ddI)
  4. foscarnet (Foscavir)

Correct answer: 3 (didanosine)


In [31]:
setup_q2 = {
    'date': '2014/07/16 01:40',
    'qid': 'Q119#2',
    'correct': 2,

    'q_text_entities': [
        'deoxyadenosine','active triphosphate','viral replication',
        'HIV reverse transcriptase','chain termination','zidovudine',
        'monotherapy','dose-dependent pancreatitis'],

    'ans_text_entities': [
        ['zalcitabine'],
        ['trifluridine'],
        ['didanosine'],
        ['foscarnet']]
}

exp3_q2 = perform_experiment_3(setup_q2)
pickle.dump(exp3_q2, open('qa-experiment3-q2.p','w'))


n: 2    (0, array([ 21.51229786,  22.64678929,  22.08065429,  22.55802286]))
n: 5    (0, array([ 21.84364688,  22.50638094,  22.02333094,  22.54458594]))
n: 10    (2, array([ 21.79308517,  22.85999879,  21.41116414,  22.35281224]))
n: 15    (2, array([ 21.90870133,  23.02195482,  21.63892807,  22.53359301]))
n: 20    (2, array([ 22.14466821,  23.21231726,  21.87577802,  22.68782217]))
n: 25    (2, array([ 22.29033837,  23.19657155,  21.95970783,  22.75818651]))
n: 50    (2, array([ 22.20045   ,  23.22139197,  21.91229803,  22.62981324]))
n: 75    (2, array([ 22.23018859,  23.23570398,  21.97575513,  22.65325387]))
n: 100    (2, array([ 22.23018859,  23.23570398,  21.97575513,  22.65325387]))
n: 200    (2, array([ 22.23018859,  23.23570398,  21.97575513,  22.65325387]))
n: 400    (2, array([ 22.23018859,  23.23570398,  21.97575513,  22.65325387]))
n: 700    (2, array([ 22.23018859,  23.23570398,  21.97575513,  22.65325387]))
n: 1000    (2, array([ 22.23018859,  23.23570398,  21.97575513,  22.65325387]))
n: 1500    (2, array([ 22.23018859,  23.23570398,  21.97575513,  22.65325387]))

Question 3 (Q34#18)

A patient is being treated with digoxin for congestive heart failure. To enhance inotropic effects, the dosage was increased. Soon afterwards, the patient complained of dizziness, fatigue, and disturbances in color vision. An ECG was taken and exhibit arrhythmias consistent with digitialis intoxication. What antiarrhythmic drugs might be used to treat worsening ventricular arrhythmias with hemodynamic compromise?

  1. amiodarone (Cordarone)
  2. lidocaine (Xylocaine)
  3. adenosine (Adenocard)
  4. propranolol (Inderal)

Correct: 2 (lidocaine)


In [38]:
setup_q3 = {
    'date': '2014/07/16 02:02',
    'qid': 'Q34#18',
    'correct': 1,

    'q_text_entities': [
        'digoxin','congestive heart failur','inotropic effects',
        'dizziness','fatigue','color vision','ECG','arrhythmias',
        'digitalis intoxication','antiarrhythmic','ventricular arrhythmias','hemodynamic compromise'],

    'ans_text_entities': [
        ['amiodarone'],
        ['lidocaine'],
        ['adenosine'],
        ['propranolol']]
}

exp3_q3 = perform_experiment_3(setup_q3)
pickle.dump(exp3_q3, open('qa-experiment3-q3.p','w'))


n: 2    (0, array([ 20.06006333,  22.571078  ,  22.490792  ,  20.74218533]))
n: 5    (0, array([ 21.27722889,  23.09539111,  23.24187472,  21.93994306]))
n: 10    (0, array([ 22.27004764,  23.57007681,  23.96398944,  22.81393083]))
n: 15    (0, array([ 22.35100337,  23.66849221,  24.20571962,  23.07998798]))
n: 20    (0, array([ 22.30176762,  23.718883  ,  24.30067946,  23.16646969]))
n: 25    (0, array([ 22.37175656,  23.59711143,  24.35948013,  23.19136331]))
n: 50    (0, array([ 22.34958375,  23.55270527,  24.63264644,  23.46030862]))
n: 75    (0, array([ 22.42731072,  23.73707266,  24.90803109,  23.65530029]))
n: 100    (0, array([ 22.25398372,  23.84604389,  24.90957679,  23.73319535]))
n: 200    (0, array([ 21.87975777,  24.24827347,  25.26523652,  24.21272107]))
n: 400    (0, array([ 21.71654188,  24.37355003,  25.39633405,  24.35635035]))
n: 700    (0, array([ 21.57820325,  24.55521344,  25.45495802,  24.35002671]))
n: 1000    (0, array([ 21.48134567,  24.67742524,  25.52923538,  24.48576022]))
n: 1500    (0, array([ 21.48440162,  24.71359471,  25.5411476 ,  24.50102922]))

Question 4 (Q16#34)

A patient is admitted for treatment of myocardial infarction. During a prolonged recovery period, the patient experienced episodes of ventricular tachycardia. Following discharge from hospital, the patient was instructed to take a drug to prevent recurrence of ventricular tachycardia. After a few days, the patient complained of dizziness and then lost consciousness. Upon admission to the hospital, the patient was found to be somewhat hypokalemic. A diagnosis of Torsades de Pointes was made. A test to determine the blood level of the antiarrhythmic reveal the drug was present in a slightly subtherapeutic level. What was the drug?

  1. sotalol (Betapace)
  2. procainamide (Procan SR, Pronestyl-SR)
  3. quinidine gluconate (Quinaglute, Quinalan)
  4. lidocaine (Xylocaine)

Correct: 3 (quinidine)


In [42]:
setup_q4 = {
    'date': '2014/07/16 02:24',
    'qid': 'Q16#34',
    'correct': 2,

    'q_text_entities': [
        'myocardial infarction', 'ventricular tachycardia','dizziness','consciousnes',
        'hypokalemic','Torsades de Pointes','antiarrhythmic'],

    'ans_text_entities': [
        ['sotalol'],
        ['procainamide'],
        ['<http://bio2rdf.org/drugbank_resource:bc2c80c68b00a7bc37b5afd1857d8b21>'], # quinedine gluconate (guinedine is also present)
        ['lidocaine']]
}

exp3_q4 = perform_experiment_3(setup_q4)
pickle.dump(exp3_q4, open('qa-experiment3-q4.p','w'))


n: 2    (0, array([ 21.74408364,  22.24665182,  26.94974273,  22.41516727]))
n: 5    (0, array([ 22.87738923,  23.02799462,  27.44206808,  23.16994885]))
n: 10    (1, array([ 23.5842398,  22.9106034,  26.5859862,  23.4515462]))
n: 15    (1, array([ 23.80127833,  22.84246097,  26.41666597,  23.44630569]))
n: 20    (1, array([ 23.57974598,  22.91830957,  26.73448543,  23.39861033]))
n: 25    (1, array([ 23.5328818 ,  23.05451919,  26.87867054,  23.49053568]))
n: 50    (1, array([ 23.60189215,  23.04819536,  27.07173503,  23.48884276]))
n: 75    (1, array([ 23.36720687,  22.97077797,  27.18525229,  23.33785335]))
n: 100    (1, array([ 23.38356603,  23.01024202,  27.2447623 ,  23.39592437]))
n: 200    (1, array([ 23.33627481,  23.04954537,  27.37692284,  23.48246321]))
n: 400    (1, array([ 23.33627481,  23.04954537,  27.37692284,  23.48246321]))
n: 700    (1, array([ 23.33627481,  23.04954537,  27.37692284,  23.48246321]))
n: 1000    (1, array([ 23.33627481,  23.04954537,  27.37692284,  23.48246321]))
n: 1500    (1, array([ 23.33627481,  23.04954537,  27.37692284,  23.48246321]))

Question 4 using different representation of answers


In [44]:
setup_q4b = {
    'date': '2014/07/16 02:34',
    'qid': 'Q16#34',
    'correct': 2,
    'comments': """
        Uses a different representation of answer 3 then in experiment3-q4. 
        Here both 'quined%%!ine' and 'quinedine gluconate' are activated.
    """,
    'q_text_entities': [
        'myocardial infarction', 'ventricular tachycardia','dizziness','consciousnes',
        'hypokalemic','Torsades de Pointes','antiarrhythmic'],

    'ans_text_entities': [
        ['sotalol'],
        ['procainamide'],
        ['<http://bio2rdf.org/drugbank:DB00908>',# both quinedine and quinedine gluconate
         '<http://bio2rdf.org/drugbank_resource:bc2c80c68b00a7bc37b5afd1857d8b21>'], 
        ['lidocaine']]
}

exp3_q4b = perform_experiment_3(setup_q4b)
pickle.dump(exp3_q4b, open('qa-experiment3-q4b.p','w'))


n: 2    (0, array([ 21.74408364,  22.24665182,  24.92111773,  22.41516727]))
n: 5    (0, array([ 22.87738923,  23.02799462,  25.52515635,  23.16994885]))
n: 10    (1, array([ 23.5842398,  22.9106034,  24.4987564,  23.4515462]))
n: 15    (1, array([ 23.80127833,  22.84246097,  24.42049549,  23.44630569]))
n: 20    (1, array([ 23.57974598,  22.91830957,  24.79774522,  23.39861033]))
n: 25    (1, array([ 23.5328818 ,  23.05451919,  24.98486919,  23.49053568]))
n: 50    (1, array([ 23.60189215,  23.04819536,  25.25590771,  23.48884276]))
n: 75    (1, array([ 23.36720687,  22.97077797,  25.46206126,  23.33785335]))
n: 100    (1, array([ 23.38356603,  23.01024202,  25.63358762,  23.39592437]))
n: 200    (1, array([ 23.33627481,  23.04954537,  25.85725483,  23.48246321]))
n: 400    (1, array([ 23.33627481,  23.04954537,  25.85725483,  23.48246321]))
n: 700    (1, array([ 23.33627481,  23.04954537,  25.85725483,  23.48246321]))
n: 1000    (1, array([ 23.33627481,  23.04954537,  25.85725483,  23.48246321]))
n: 1500    (1, array([ 23.33627481,  23.04954537,  25.85725483,  23.48246321]))

Question 4 using yet another representation of answers


In [45]:
setup_q4c = {
    'date': '2014/07/16 02:34',
    'qid': 'Q16#34',
    'correct': 2,
    'comments': """
        Uses a different representation of answer 3 then in experiment3-q4
        and experiment3-q4b. Here only quinedine is activated.
    """,
    'q_text_entities': [
        'myocardial infarction', 'ventricular tachycardia','dizziness','consciousnes',
        'hypokalemic','Torsades de Pointes','antiarrhythmic'],

    'ans_text_entities': [
        ['sotalol'],
        ['procainamide'],
        ['<http://bio2rdf.org/drugbank:DB00908>'], # quinedine 
        ['lidocaine']]
}

exp3_q4c = perform_experiment_3(setup_q4c)
pickle.dump(exp3_q4c, open('qa-experiment3-q4c.p','w'))


n: 2    (0, array([ 21.74408364,  22.24665182,  22.89249273,  22.41516727]))
n: 5    (0, array([ 22.87738923,  23.02799462,  23.60824462,  23.16994885]))
n: 10    (2, array([ 23.5842398,  22.9106034,  22.4115266,  23.4515462]))
n: 15    (2, array([ 23.80127833,  22.84246097,  22.424325  ,  23.44630569]))
n: 20    (2, array([ 23.57974598,  22.91830957,  22.861005  ,  23.39861033]))
n: 25    (1, array([ 23.5328818 ,  23.05451919,  23.09106784,  23.49053568]))
n: 50    (1, array([ 23.60189215,  23.04819536,  23.44008039,  23.48884276]))
n: 75    (1, array([ 23.36720687,  22.97077797,  23.73887022,  23.33785335]))
n: 100    (1, array([ 23.38356603,  23.01024202,  24.02241294,  23.39592437]))
n: 200    (1, array([ 23.33627481,  23.04954537,  24.33758682,  23.48246321]))
n: 400    (1, array([ 23.33627481,  23.04954537,  24.33758682,  23.48246321]))
n: 700    (1, array([ 23.33627481,  23.04954537,  24.33758682,  23.48246321]))
n: 1000    (1, array([ 23.33627481,  23.04954537,  24.33758682,  23.48246321]))
n: 1500    (1, array([ 23.33627481,  23.04954537,  24.33758682,  23.48246321]))

Question 5 (Q26#11)

An elderly male patient has essential hypertension, congestive heart failure, and type I insulin-dependent diabetes. His congestive failure developed secondary to coronary vascular disease associated with hyperlipidemia. What antihypertensive drug(s) may be most appropriate for this patient?

  1. chlorothiazide (Diuril)
  2. captopril (Capoten)
  3. propranolol (Inderal)
  4. metoprolol (Lopressor)

Correct: 2 (captopril)


In [47]:
setup_q5 = {
    'date': '2014/07/16 02:14',
    'qid': 'Q26#11',
    'correct': 1,

    'q_text_entities': [
        'essential hypertension','hypertension','congestive heart failure',
        'type i diabetes', 'insulin-dependent','diabetes',
        'coronary vascular disease','hyperlipidemia','antihypertensive'
],

    'ans_text_entities': [
        ['chlorothiazide'],
        ['captopril'],
        ['propranolol'],
        ['metoprolol']]
}

exp3_q5 = perform_experiment_3(setup_q5)
pickle.dump(exp3_q5, open('qa-experiment3-q5.p','w'))


n: 2    (2, array([ 20.96666294,  21.21187882,  20.39771882,  20.53382235]))
n: 5    (2, array([ 22.29558421,  22.33256842,  22.00330105,  22.00953789]))
n: 10    (2, array([ 22.50954699,  22.37335411,  21.63973384,  21.93232959]))
n: 15    (2, array([ 22.97327563,  22.72625243,  22.40185854,  22.50517505]))
n: 20    (2, array([ 23.10227752,  22.91656705,  22.72703907,  22.76892868]))
n: 25    (3, array([ 23.03611359,  22.94305922,  22.90173007,  22.88819196]))
n: 50    (0, array([ 23.17015522,  23.34574557,  23.32236343,  23.33799717]))
n: 75    (0, array([ 23.11494948,  23.52455513,  23.48543671,  23.50102226]))
n: 100    (0, array([ 22.94021886,  23.37646765,  23.27164227,  23.26773475]))
n: 200    (0, array([ 22.64450014,  23.05283353,  23.68918669,  23.09196184]))
n: 400    (0, array([ 22.77139023,  23.11536123,  23.49832039,  23.06233544]))
n: 700    (0, array([ 22.79572675,  23.13191433,  23.49881099,  23.08492668]))
n: 1000    (0, array([ 22.79572675,  23.13191433,  23.49881099,  23.08492668]))
n: 1500    (0, array([ 22.79572675,  23.13191433,  23.49881099,  23.08492668]))

Question 6 (Q121#5)

Mainly eliminated by renal mechanisms as the hypoxanthine metabolite, this antiviral agent is effective for treating acute keratoconjunctivitis (ointment) and HSV encephalitis (i.v.)

  1. vidarabine (Vira-A)
  2. ganciclovir (DHPG, Cytovene)
  3. foscarnet (Foscavir)
  4. zidovudine (Retrovir, AZT, azidothymidine)

Correct: 1 (vidarabine)


In [48]:
setup_q6 = {
    'date': '2014/07/16 02:47',
    'qid': 'Q121#5',
    'correct': 0,

    'q_text_entities': [
        'renal mechanisms', 'hypoxanthine metabolite','antiviral agent',
        'keratoconjunctivitis', 'HSV','encephalitis' # with and without ointment?
        'coronary vascular disease','hyperlipidemia','antihypertensive'
],

    'ans_text_entities': [
        ['chlorothiazide'],
        ['captopril'],
        ['propranolol'],
        ['<http://bio2rdf.org/drugbank_resource:4ae6628acf456f373bb1241494313680>',
         '<http://bio2rdf.org/wikipedia:Zidovudine>']]
}

exp3_q6 = perform_experiment_3(setup_q6)
pickle.dump(exp3_q6, open('qa-experiment3-q6.p','w'))


n: 2    (0, array([ 22.95959154,  23.32534154,  23.67762846,  27.2791    ]))
n: 5    (0, array([ 23.43662276,  24.21747655,  24.23806207,  27.06378414]))
n: 10    (0, array([ 23.19296702,  23.59726807,  23.89515825,  25.85351684]))
n: 15    (1, array([ 23.44932861,  23.31183937,  24.14671025,  25.74263551]))
n: 20    (1, array([ 23.3804372 ,  23.11159065,  23.99675065,  25.56831866]))
n: 25    (1, array([ 23.39522612,  23.24719417,  24.08713136,  25.66609811]))
n: 50    (0, array([ 23.20763993,  23.46282581,  24.03942044,  25.72473743]))
n: 75    (0, array([ 22.81098193,  23.47337422,  23.93221689,  25.79445252]))
n: 100    (0, array([ 22.53696406,  23.24932967,  23.47447883,  25.75335275]))
n: 200    (0, array([ 21.76846596,  22.30182114,  23.91512086,  26.58914954]))
n: 400    (0, array([ 21.9092202 ,  22.48537245,  23.9211828 ,  26.86539332]))
n: 700    (0, array([ 21.91154799,  22.52997595,  23.87355279,  26.89242651]))
n: 1000    (0, array([ 21.91154799,  22.52997595,  23.87355279,  26.89242651]))
n: 1500    (0, array([ 21.91154799,  22.52997595,  23.87355279,  26.89242651]))

In [49]:
setup_q6b = {
    'date': '2014/07/16 02:47',
    'qid': 'Q121#5',
    'correct': 0,
    'comment': 'Different representation of question: added "ointment"',

    'q_text_entities': [
        'renal mechanisms', 'hypoxanthine metabolite','antiviral agent',
        'keratoconjunctivitis', 'HSV','encephalitis', 'ointment',
        'coronary vascular disease','hyperlipidemia','antihypertensive'
],

    'ans_text_entities': [
        ['chlorothiazide'],
        ['captopril'],
        ['propranolol'],
        ['<http://bio2rdf.org/drugbank_resource:4ae6628acf456f373bb1241494313680>',
         '<http://bio2rdf.org/wikipedia:Zidovudine>']]
}

exp3_q6b = perform_experiment_3(setup_q6b)
pickle.dump(exp3_q6b, open('qa-experiment3-q6b.p','w'))


n: 2    (0, array([ 23.35380294,  23.60924765,  23.99898235,  27.51535382]))
n: 5    (0, array([ 23.48616892,  23.91318622,  24.08607378,  26.99942797]))
n: 10    (0, array([ 23.4086258 ,  23.65614652,  24.03586536,  26.1183008 ]))
n: 15    (1, array([ 23.70082969,  23.53393031,  24.33926792,  26.08670729]))
n: 20    (1, array([ 23.7053173 ,  23.44534278,  24.28701417,  26.00877765]))
n: 25    (1, array([ 23.77565562,  23.63589231,  24.43286915,  26.14397538]))
n: 50    (0, array([ 23.68981134,  23.86490663,  24.4377611 ,  26.21153538]))
n: 75    (0, array([ 23.5140379 ,  23.90222895,  24.33840952,  26.32371048]))
n: 100    (0, array([ 23.63553591,  23.84181764,  24.03762445,  26.42946689]))
n: 200    (0, array([ 23.09146809,  23.18340847,  24.30290084,  27.01446703]))
n: 400    (1, array([ 23.57502535,  23.49596919,  24.37976422,  27.28423192]))
n: 700    (1, array([ 23.63580952,  23.61640476,  24.35594997,  27.31559078]))
n: 1000    (1, array([ 23.63580952,  23.61640476,  24.35594997,  27.31559078]))
n: 1500    (1, array([ 23.63580952,  23.61640476,  24.35594997,  27.31559078]))

Different questions & answers


In [50]:
setup_q7 = {
    'date': '2014/07/16 03:03',
    'qid': 'Q16#34 and Q119#2',
    'correct': None,
    'comments': """
        Merging the question of Question 4 and the anser from question 2. The question
        being: is there a difference in the rough distance?
    """,
    'q_text_entities': [
        'myocardial infarction', 'ventricular tachycardia','dizziness','consciousnes',
        'hypokalemic','Torsades de Pointes','antiarrhythmic'],

    'ans_text_entities': [
        ['zalcitabine'],
        ['trifluridine'],
        ['didanosine'],
        ['foscarnet']]
}

exp3_q7 = perform_experiment_3(setup_q7)
pickle.dump(exp3_q7, open('qa-experiment3-q7.p','w'))


n: 2    (2, array([ 22.75746364,  22.78756636,  22.75036636,  23.1828    ]))
n: 5    (2, array([ 23.57656346,  23.48294269,  23.20445538,  23.91856   ]))
n: 10    (0, array([ 23.7936748,  24.0231548,  23.8910342,  24.1691248]))
n: 15    (0, array([ 23.96513639,  24.03512278,  24.07261042,  24.21971486]))
n: 20    (0, array([ 23.88529707,  23.92402424,  24.02710163,  24.11337685]))
n: 25    (0, array([ 23.8215127 ,  23.92292631,  24.02166486,  24.08822676]))
n: 50    (1, array([ 23.75613928,  23.7050268 ,  23.90977641,  23.8840968 ]))
n: 75    (1, array([ 23.50405727,  23.42609502,  23.61910736,  23.58714454]))
n: 100    (1, array([ 23.45931143,  23.37277948,  23.58103607,  23.53101353]))
n: 200    (1, array([ 23.37766509,  23.30215886,  23.47593043,  23.46619145]))
n: 400    (1, array([ 23.37766509,  23.30215886,  23.47593043,  23.46619145]))
n: 700    (1, array([ 23.37766509,  23.30215886,  23.47593043,  23.46619145]))
n: 1000    (1, array([ 23.37766509,  23.30215886,  23.47593043,  23.46619145]))
n: 1500    (1, array([ 23.37766509,  23.30215886,  23.47593043,  23.46619145]))

Use this procedure for question 1 as well

A patient with Type I diabetes presents with significant water retention and pulmonary congestion. Serum creatinine, BUN and potassium were significantly elevated. The diagnosis was advanced renal failure. A diuretic was given to treat water retention, but shortly thereafter the patient exhibited cardiac conduction changes which progressed to heart block and cardiac arrest. The diuretic which was determined to cause this event was probably:

  1. furosemide (Lasix)
  2. triamterene (Dyrenium)
  3. chlorothiazide (Diuril)
  4. bumetanide (Bumex)

Correct answer: 2 (Triamrene)


In [4]:
setup_q1b = {
    'date': '2014/07/16 12:09',
    'qid': 'Q83#4',
    'correct': 2,
    'comments': """
        Repeating experiment for question 1
    """,
    'q_text_entities': [
    'diabetes', 'water retention','pulmonary congestion',
    'Serum creatinine','BUN','potassium', 'renal failure',
    'cardiac conduction','heart block','carciac arrest'],

    'ans_text_entities': [
        ['furosemide'],
        ['triamterene'],
        ['chlorothiazide'],
        ['bumetanide']]
}

exp3_q1b = perform_experiment_3(setup_q1b)
pickle.dump(exp3_q1b, open('qa-experiment3-q1b.p','w'))


n: 2    (2, array([ 23.39311333,  23.64160133,  22.85465467,  23.19914   ]))
n: 5    (3, array([ 23.69026486,  23.96474486,  23.50753757,  23.4165873 ]))
n: 10    (3, array([ 23.89699507,  24.0457229 ,  23.72558507,  23.38999913]))
n: 15    (3, array([ 23.66602578,  23.93796333,  23.704398  ,  23.43836422]))
n: 20    (3, array([ 23.65750717,  23.98169619,  23.72958381,  23.42223593]))
n: 25    (3, array([ 23.7774389 ,  24.21629022,  23.93702199,  23.74483007]))
n: 50    (3, array([ 23.95271402,  24.06882124,  23.9898266 ,  23.81234057]))
n: 75    (3, array([ 23.93419863,  23.90534655,  23.96751655,  23.75193996]))
n: 100    (1, array([ 24.04496937,  23.85083129,  24.22357205,  23.89962659]))
n: 200    (1, array([ 24.0362576 ,  23.87592381,  24.22544358,  24.06389876]))
n: 400    (1, array([ 24.25994767,  24.22528611,  24.43905009,  24.69141694]))
n: 700    (1, array([ 24.45938843,  24.40501697,  24.58805683,  24.69060553]))
n: 1000    (1, array([ 24.49538787,  24.26544081,  24.70928831,  24.79912691]))
n: 1500    (1, array([ 24.49538787,  24.26544081,  24.70928831,  24.79912691]))

More precision for question 1


In [8]:
%%time
setup_q1c = {
    'date': '2014/07/16 14:00',
    'qid': 'Q83#4',
    'correct': 2,
    'comments': "Question 1 but with more measurements",
    'q_text_entities': [
    'diabetes', 'water retention','pulmonary congestion',
    'Serum creatinine','BUN','potassium', 'renal failure',
    'cardiac conduction','heart block','carciac arrest'],

    'ans_text_entities': [
        ['furosemide'],
        ['triamterene'],
        ['chlorothiazide'],
        ['bumetanide']]
}
# Can add at most 1349 question nodes

exp3_q1c = perform_experiment_3(setup_q1c,range(5,500,5))
pickle.dump(exp3_q1c, open('qa-experiment3-q1c.p','w'))


n: 5    (3, array([ 23.69026486,  23.96474486,  23.50753757,  23.4165873 ]))
n: 10    (3, array([ 23.89699507,  24.0457229 ,  23.72558507,  23.38999913]))
n: 15    (3, array([ 23.66602578,  23.93796333,  23.704398  ,  23.43836422]))
n: 20    (3, array([ 23.65750717,  23.98169619,  23.72958381,  23.42223593]))
n: 25    (3, array([ 23.7774389 ,  24.21629022,  23.93702199,  23.74483007]))
n: 30    (3, array([ 23.89084236,  24.20262108,  23.98121142,  23.82691885]))
n: 35    (3, array([ 23.85423258,  24.13430943,  23.94850925,  23.77650057]))
n: 40    (3, array([ 23.88741924,  24.11064129,  23.94807193,  23.81188135]))
n: 45    (3, array([ 23.91874262,  24.09295536,  23.99327104,  23.82078082]))
n: 50    (3, array([ 23.95271402,  24.06882124,  23.9898266 ,  23.81234057]))
n: 55    (3, array([ 23.96738771,  24.09577971,  23.99091405,  23.75307332]))
n: 60    (3, array([ 23.96990293,  24.09011247,  24.01866837,  23.74961079]))
n: 65    (3, array([ 23.98422229,  24.08284727,  24.02189921,  23.74933335]))
n: 70    (3, array([ 23.86007838,  23.93526245,  23.90869303,  23.66089876]))
n: 75    (3, array([ 23.93419863,  23.90534655,  23.96751655,  23.75193996]))
n: 80    (3, array([ 24.00587307,  23.87167237,  24.0780427 ,  23.82761363]))
n: 85    (1, array([ 24.01702526,  23.80893646,  24.10882663,  23.85630211]))
n: 90    (1, array([ 24.05742424,  23.7860233 ,  24.17127286,  23.89964407]))
n: 95    (1, array([ 24.05427039,  23.82661844,  24.19648671,  23.91092993]))
n: 100    (1, array([ 24.04496937,  23.85083129,  24.22357205,  23.89962659]))
n: 105    (1, array([ 24.01722341,  23.85745936,  24.23035418,  23.86926064]))
n: 110    (1, array([ 23.99310185,  23.82318616,  24.29542103,  23.85850971]))
n: 115    (1, array([ 23.98223457,  23.82428138,  24.27462897,  23.85412003]))
n: 120    (1, array([ 23.99557085,  23.83527739,  24.28312686,  23.8636751 ]))
n: 125    (1, array([ 24.00388423,  23.8432644 ,  24.28218246,  23.8705384 ]))
n: 130    (1, array([ 24.01960019,  23.85673503,  24.28476635,  23.88263931]))
n: 135    (1, array([ 24.02608606,  23.84888488,  24.28727838,  23.89084213]))
n: 140    (1, array([ 24.03346529,  23.85382151,  24.29859696,  23.9151354 ]))
n: 145    (1, array([ 24.05285178,  23.87050446,  24.32127567,  23.94052335]))
n: 150    (1, array([ 24.093877  ,  23.91940627,  24.36086126,  23.96858904]))
n: 155    (1, array([ 24.09407216,  23.89565941,  24.36665671,  23.9958013 ]))
n: 160    (1, array([ 24.09403573,  23.88415182,  24.37013933,  24.02104046]))
n: 165    (1, array([ 24.09924696,  23.89049721,  24.33104131,  24.04107532]))
n: 170    (1, array([ 24.07438921,  23.86795349,  24.28175256,  24.01303443]))
n: 175    (1, array([ 24.02882982,  23.83053101,  24.24380508,  23.97076785]))
n: 180    (1, array([ 23.98797605,  23.7993612 ,  24.19600273,  23.93562233]))
n: 185    (1, array([ 23.98656467,  23.81406062,  24.20570355,  23.94925306]))
n: 190    (1, array([ 23.99744726,  23.83046853,  24.20937654,  23.98164943]))
n: 195    (1, array([ 24.00242236,  23.84449861,  24.20506484,  24.01227028]))
n: 200    (1, array([ 24.0362576 ,  23.87592381,  24.22544358,  24.06389876]))
n: 205    (1, array([ 24.03333536,  23.87471908,  24.22758768,  24.08200253]))
n: 210    (1, array([ 24.03333536,  23.87471908,  24.22758768,  24.08200253]))
n: 215    (1, array([ 24.03150169,  23.87401367,  24.22541643,  24.07895445]))
n: 220    (1, array([ 24.04899398,  23.89974348,  24.24729422,  24.1329859 ]))
n: 225    (1, array([ 24.05697764,  23.91891265,  24.26159337,  24.1599101 ]))
n: 230    (1, array([ 24.06253339,  23.91217194,  24.26725274,  24.15816998]))
n: 235    (1, array([ 24.06108216,  23.87671769,  24.26401137,  24.15571733]))
n: 240    (1, array([ 24.06108216,  23.87671769,  24.26401137,  24.15571733]))
n: 245    (1, array([ 24.07461177,  23.88942563,  24.27659116,  24.17611144]))
n: 250    (1, array([ 24.09412513,  23.92001569,  24.29883099,  24.22830907]))
n: 255    (1, array([ 24.11199261,  23.94075143,  24.31655713,  24.27142627]))
n: 260    (1, array([ 24.12470475,  23.96375316,  24.3314211 ,  24.30682521]))
n: 265    (1, array([ 24.12357078,  23.97270116,  24.339657  ,  24.31606347]))
n: 270    (1, array([ 24.12160273,  23.95903902,  24.33279576,  24.31274564]))
n: 275    (1, array([ 24.1330456 ,  23.98603078,  24.35066548,  24.35738752]))
n: 280    (1, array([ 24.15338171,  24.01542079,  24.37320415,  24.40810401]))
n: 285    (1, array([ 24.15509721,  24.01890112,  24.37349781,  24.4104931 ]))
n: 290    (1, array([ 24.13610838,  23.99344538,  24.35200253,  24.38750842]))
n: 295    (1, array([ 24.1465546 ,  24.00752976,  24.36210283,  24.4127528 ]))
n: 300    (1, array([ 24.16913812,  24.03353112,  24.38295996,  24.45127591]))
n: 305    (1, array([ 24.16611475,  24.05020479,  24.39319989,  24.43854823]))
n: 310    (1, array([ 24.18529573,  24.07138407,  24.41080602,  24.46297922]))
n: 315    (1, array([ 24.19682038,  24.08888499,  24.41988792,  24.48870712]))
n: 320    (1, array([ 24.13575987,  24.08175434,  24.41197204,  24.47228616]))
n: 325    (1, array([ 24.13575738,  24.07390288,  24.41147616,  24.47255288]))
n: 330    (1, array([ 24.15676624,  24.10104333,  24.43388536,  24.51682713]))
n: 335    (1, array([ 24.17210684,  24.12038897,  24.44905458,  24.5410503 ]))
n: 340    (1, array([ 24.16760648,  24.07995315,  24.43632724,  24.52992946]))
n: 345    (1, array([ 24.17459986,  24.08896223,  24.4366143 ,  24.53428548]))
n: 350    (1, array([ 24.19582583,  24.11464411,  24.45892063,  24.57425968]))
n: 355    (1, array([ 24.21548284,  24.14040147,  24.47413598,  24.6050353 ]))
n: 360    (1, array([ 24.20950387,  24.13785382,  24.42290136,  24.58341285]))
n: 365    (1, array([ 24.21267226,  24.15353718,  24.41757846,  24.59418688]))
n: 370    (1, array([ 24.23144308,  24.18074519,  24.43973448,  24.64090199]))
n: 375    (1, array([ 24.24895564,  24.20645895,  24.46170691,  24.68609382]))
n: 380    (1, array([ 24.25425619,  24.21589379,  24.46507595,  24.69315412]))
n: 385    (1, array([ 24.25926428,  24.2188971 ,  24.46546655,  24.6941901 ]))
n: 390    (1, array([ 24.26485594,  24.22267882,  24.46286518,  24.69446984]))
n: 395    (1, array([ 24.27371532,  24.23582735,  24.464391  ,  24.7093126 ]))
n: 400    (1, array([ 24.25994767,  24.22528611,  24.43905009,  24.69141694]))
n: 405    (1, array([ 24.25418306,  24.21611836,  24.42259433,  24.68083912]))
n: 410    (1, array([ 24.24842761,  24.20842735,  24.38512698,  24.67034509]))
n: 415    (1, array([ 24.250176  ,  24.21178008,  24.37020845,  24.66415669]))
n: 420    (1, array([ 24.25180469,  24.21325183,  24.37012284,  24.66402026]))
n: 425    (1, array([ 24.25022143,  24.1953296 ,  24.36349638,  24.65867907]))
n: 430    (1, array([ 24.25033667,  24.19904797,  24.36367172,  24.6533541 ]))
n: 435    (1, array([ 24.24867365,  24.19247437,  24.35908794,  24.64994673]))
n: 440    (1, array([ 24.24673347,  24.18213122,  24.34929608,  24.64207262]))
n: 445    (1, array([ 24.25268575,  24.17876176,  24.35065575,  24.64334105]))
n: 450    (1, array([ 24.25289386,  24.17641121,  24.34911398,  24.64170912]))
n: 455    (1, array([ 24.25724627,  24.17271625,  24.34936382,  24.64227246]))
n: 460    (1, array([ 24.25365762,  24.15655221,  24.34965615,  24.64245193]))
n: 465    (1, array([ 24.24557498,  24.14612902,  24.34926189,  24.63917655]))
n: 470    (1, array([ 24.24850185,  24.14993769,  24.34577999,  24.63974311]))
n: 475    (1, array([ 24.25197473,  24.14800738,  24.34609201,  24.63993702]))
n: 480    (1, array([ 24.26089563,  24.15661696,  24.35422272,  24.65061933]))
n: 485    (1, array([ 24.28110567,  24.17629669,  24.37151881,  24.67283353]))
n: 490    (1, array([ 24.29733427,  24.19672538,  24.39326592,  24.68969506]))
n: 495    (1, array([ 24.29762053,  24.20011859,  24.39542457,  24.68887384]))
CPU times: user 1h 36min 56s, sys: 2min 5s, total: 1h 39min 2s
Wall time: 1h 43min 17s

In [ ]: